package com.oo.fileexplorer.tools;

import android.os.Environment;

import java.io.File;
import java.util.ArrayList;

/**
 * Created by zhuxiaolong on 2017/12/22.
 */

public class FileScanner {

    public static ArrayList<FilePype> scanDisk() {
        return scanDirectory("");
    }

    public static ArrayList<FilePype> scanDirectory(String path) {
        File file = new File(Environment.getExternalStorageDirectory().getPath() + "/" + path);
        ArrayList<FilePype> list = new ArrayList<>();

        if (file.exists()) {
            if (file.isDirectory()) {
                if (file.list() != null) {
                    for (String s : file.list()) {
                        list.add(new FilePype(s));
                    }
                }
            }
        }
        return list;
    }


    public static class FilePype {
        public FilePype(String fileName) {
            this.fileName = fileName;
        }

        public String fileName;
        public boolean isDir;
        public boolean isFile;
        public boolean isImg;
        public boolean isMedia;
    }



}
